package com.cheng.system.controller;

import com.cheng.common.annotation.JWTIgnore;
import com.cheng.common.domain.R;
import com.cheng.system.model.Setting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/setting")
public class SettingController {
    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @JWTIgnore
    @PostMapping("save")
    public R<Boolean> save(@RequestBody Setting setting) {
        redisTemplate.opsForValue().set("file:setting:" + setting.getAppId(), setting);
        return R.ok(true);
    }

    @JWTIgnore
    @GetMapping("get")
    public R<Setting> getSetting(String appId) {
        Setting o = (Setting) redisTemplate.opsForValue().get("file:setting:" + appId);
        return R.ok(o);
    }
}
